home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacWT 0.9 / wt Mac Source / Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-13  |  1.9 KB  |  112 lines  |  [TEXT/CWIE]

  1. /*
  2. ** File:        Main.c
  3. **
  4. ** Written by:    Bill Hayden
  5. **                Nikol Software
  6. **
  7. ** Copyright © 1995 Nikol Software
  8. ** All rights reserved.
  9. */
  10.  
  11.  
  12.  
  13. #include "AEHandler.h"
  14. #include "Failure.h"
  15. #include "wt.h"
  16. #include "MacWT.h"
  17. #include "Constants.h"
  18. #include "Menu.h"
  19. #include "StringUtils.h"
  20. #include "Init.h"
  21. #include "FileUtils.h"
  22. #include "Networking.h"
  23. #include "Event.h"
  24.  
  25.  
  26.  
  27. // profiling code
  28. #if __profile__
  29.  
  30. #include "Profiler.h"
  31.  
  32. #if GENERATINGPOWERPC
  33. #define SUFFIX "PPC"
  34. #else
  35. #define SUFFIX "68K"
  36. #endif
  37.  
  38. #endif
  39.  
  40.  
  41. EventRecord    gTheEvent;
  42. Boolean        quitting = false;
  43. Boolean        gPaused = false;
  44. Boolean        gShowFPS = true;
  45. Boolean        gGameOn = false;
  46. Boolean        gTrueColor = false;
  47. Boolean        gKeyboardControl = true;
  48. Boolean        gUseQuickdraw = true;
  49. Boolean        gDrawFC = true;
  50. short        gScreenDepth = 0;
  51. short        gCurrentDepth = 0;
  52. short        gSizeOfPixel = 1;
  53. Str255        gWorldFile = "\p";
  54. Str15        gWTVersion = "\pUnknown";
  55. OSErr        gNetworkErr = noErr;
  56.  
  57. #if    __ppcc
  58. QDGlobals     qd;
  59. #endif
  60.  
  61.  
  62.  
  63.  
  64. /*****************************************************************************/
  65.  
  66.  
  67.  
  68. void main(void)
  69. {
  70.     KeyMap            kmap;
  71.     unsigned char    *kmp = (unsigned char *)&kmap;
  72.     NamesTableEntry    appNTE;
  73.     EntityName        appEntityName;
  74.     
  75.  
  76.     MaxApplZone();                            // Expand the heap so code segments load at the top.
  77.     Initialize(32, kMinHeap, kMinSpace);    // Initialize the program.
  78.     
  79.     GetKeys(kmap);
  80.     if MacKeyDown(kmp, 0x3A) QuitEverythingButMe();    // option key quits all other apps
  81.     
  82.     InitAppleEvents();
  83.     DoAdjustMenus();
  84.  
  85. #if GENERATING68K
  86.     UnloadSeg((Ptr)Initialize);                // Initialize can't be in Main Segment!
  87. #endif
  88.  
  89.     while (ProcessEvent()) {};                // Handle 'odoc' AppleEvent et al.
  90.  
  91.     InitMacWT();
  92.  
  93.     gNetworkErr = AddPPCNBPAlias(&appNTE, "\pMacWT", &appEntityName);
  94.     
  95. #if __profile__
  96.     if (!ProfilerInit(collectDetailed, bestTimeBase, 20, 5))
  97.     {
  98. #endif
  99.  
  100.     EventLoop();
  101.  
  102. #if __profile__
  103.         ProfilerDump("\pMacWT(" SUFFIX ").prof");
  104.         ProfilerTerm();
  105.     }
  106. #endif
  107.  
  108.     DisposeMacWT();
  109.         
  110.     if (!gNetworkErr) RemoveNBPAlias(&appEntityName);
  111. }
  112.